#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n, x;
	cin >> n >> x;
	int digit = 0; int j = 0;
	for (int i = 1; i <= n; i++) {
		j = i;
		while (j > 0) {
			if (j % 10 == x)digit++;
			j /= 10;
		}
	}
	cout << digit;
	return 0;
}